package com.timbo.service.system.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.timbo.dao.system.SysDepartDao;
import com.timbo.model.system.SysDepart;
import com.timbo.service.system.ISysDepartSV;
import com.timbo.util.db.Criteria;

@Service("sysDepartSV")
public class SysDepartSVImpl implements ISysDepartSV {

	@Autowired
	private SysDepartDao<SysDepart> sysDepartDao;
	
	@Override
	public SysDepart queryDepartById(String id) {
		
		SysDepart sysDepart = sysDepartDao.queryById(id);
		return sysDepart;
	}

	@Override
	public List<SysDepart> queryDepartsByIds(List<String> ids) {
		
		List<SysDepart> departList = sysDepartDao.queryDepartsByIds(ids);
		return departList;
	}

	@Override
	public List<SysDepart> queryAllDepart() {
		
		List<SysDepart> departs = sysDepartDao.query(new SysDepart());
		return departs;
	}

	@Override
	public List<SysDepart> queryAllTopDepart() {
		
		SysDepart sysDepart = new SysDepart();
		Criteria criteria = new Criteria();
		criteria.add("parentdepartid", "is null");
		sysDepart.setCriteria(criteria);
		List<SysDepart> topDeaprts = sysDepartDao.query(sysDepart);
		return topDeaprts;
	}

}
